package com.hstc.controller;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
public class OllamaController {
//    方法一：
    @Resource(name = "ollamaChatModel")
    private ChatModel chatModel;
//    方法二：
//    @Qualifier("ollamaChatModel")
//    private ChatModel chatModel;

    @GetMapping("/ollama/dochat")
    public String doChat(@RequestParam(name = "msg",defaultValue = "你是谁") String msg){
        return chatModel.call(msg);
    }

    @GetMapping("/ollama/streamchat")
    public Flux<String> streamChat(@RequestParam(name = "msg",defaultValue = "你是谁") String msg){
        return chatModel.stream(msg);
    }
}
